package GUI;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;


@SuppressWarnings("serial")
/**
 * Views the logged-in user's card 
 * @author Benny
 */
public class ViewUserCardGUI extends JPanel {
	
	public JTextField textName;
	public JTextField textID;
	public JTextField textEmail;
	public JTextField textPhone;
	public JTextField textUserStatus;
	public DefaultTableModel searchTableModel1;
    public JTable table1;
    public JScrollPane scrollPane1;
	
	public MainFrame mf;
	/**
	 * Create the panel.
	 * @param M Instance of the main Frame of the program 
	 */
	public ViewUserCardGUI(MainFrame M) {
		setLayout(null);
		this.mf=M;
		
		JLabel lblViewUserCard = new JLabel("View User Card");
		lblViewUserCard.setFont(new Font("Segoe UI", Font.BOLD, 16));
		lblViewUserCard.setBounds(207, 12, 180, 23);
		add(lblViewUserCard);
		
		JLabel lblName = new JLabel("Name:");
		lblName.setBounds(144, 61, 151, 14);
		add(lblName);
		
		JLabel lblId = new JLabel("Id:");
		lblId.setBounds(144, 86, 151, 14);
		add(lblId);
		
		JLabel lblEmail = new JLabel("Email:");
		lblEmail.setBounds(144, 111, 151, 14);
		add(lblEmail);
		
		JLabel lblPhone = new JLabel("Phone:");
		lblPhone.setBounds(144, 136, 151, 14);
		add(lblPhone);
		
		JLabel lblUserStatus = new JLabel("User Status:");
		lblUserStatus.setBounds(144, 164, 151, 14);
		add(lblUserStatus);
		
		searchTableModel1= new DefaultTableModel();
        searchTableModel1.addColumn("Name");
        searchTableModel1.addColumn("CopyID");
        searchTableModel1.addColumn("Return Date");
        searchTableModel1.addColumn("Status");

		scrollPane1 = new JScrollPane();
		scrollPane1.setBounds(10, 229, 488, 200);
		add(scrollPane1);
		
		table1= new JTable(searchTableModel1){
		        
		        public boolean isCellEditable(int rowIndex, int colIndex) {
		                  return false; //Disallow the editing of any cell
		                  }
		                  };
		
        
        scrollPane1.setViewportView(table1);
        table1.setRowSelectionAllowed(true);
        table1.setVisible(true);
		
		textName = new JTextField();
		textName.setEditable(false);
		textName.setBounds(292, 58, 126, 20);
		add(textName);
		textName.setColumns(10);
		
		textID = new JTextField();
		textID.setEditable(false);
		textID.setBounds(292, 83, 126, 20);
		add(textID);
		textID.setColumns(10);
		
		textEmail = new JTextField();
		textEmail.setEditable(false);
		textEmail.setBounds(292, 108, 126, 20);
		add(textEmail);
		textEmail.setColumns(10);
		
		textPhone = new JTextField();
		textPhone.setEditable(false);
		textPhone.setBounds(292, 133, 126, 20);
		add(textPhone);
		textPhone.setColumns(10);
		
		textUserStatus = new JTextField();
		textUserStatus.setEditable(false);
		textUserStatus.setBounds(292, 161, 126, 20);
		add(textUserStatus);
		textUserStatus.setColumns(10);
		
		ImageIcon img = new ImageIcon(getClass().getResource(
                "/util/grad2.jpg"));
		
		JLabel lblMyActiveBorrows = new JLabel("My Active Borrows:");
		lblMyActiveBorrows.setBounds(26, 204, 118, 14);
		add(lblMyActiveBorrows);
		JLabel picLabel = new JLabel(img);
		picLabel.setLocation(0, 0);
		picLabel.setSize(683, 575);
		add(picLabel);
		this.setVisible(true);
		

	}
}
